﻿/*----------------------------------------------------------------
// Copyright (C) 2011 上海
// 版权所有。 
//
// 文件名：DataAccessSporadicInfoSel
// 文件功能描述：零星物品库存查询数据访问层
//
// 
// 创建标识：2012-04-01 王冲
//
// 修改标识：
// 修改描述：
//
//
//----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DbAdapter.sqldbAdapter;
using System.Data.SqlClient;

namespace DAO.WaiGaoQiao
{
    public class DataAccessSporadicInfoSel
    {
        /// <summary>
        /// 零星物品库存数量
        /// </summary>
        /// <returns></returns>
        public int GetSporadicInfoSelCount()
        {
            sqldb db = new sqldb();
            string query = "select count(1) from CON_Goods_Stocks_Sporadic_View";
            object rowcount = db.ExecuteScalar(GetConntionString.conntionstring(), CommandType.Text, query);
            return Convert.ToInt32(rowcount);
        }

        /// <summary>
        /// 零星物品库存信息
        /// </summary>
        /// <returns></returns>
        public DataSet SelSporadicInfoSelInfo(int pagesize, int startindex, string strquery)
        {
            using (SqlConnection conn = new SqlConnection(GetConntionString.conntionstring()))
            {
                sqldb db = new sqldb();
                int startrow = pagesize * (startindex - 1);
                int endrow = pagesize * startindex + 1;
                string query = "select * from (select ROW_NUMBER() OVER(ORDER BY GOODSNO ASC) rownumber,* " +
                               "from CON_Goods_Stocks_Sporadic_View where STOCKS_COUNT!=0) B "
                             + "where B.rownumber > " + startrow.ToString() + " and B.rownumber < " + endrow.ToString() + strquery;
                DataSet ds = db.ExecuteDataset(conn, CommandType.Text, query);
                return ds;
            }
        }
    }
}
